﻿#pragma execution_character_set("utf-8")
/*
 * 通信普通操作delegate
 */
#ifndef COMMUNICATENORMALDELEGATE_H
#define COMMUNICATENORMALDELEGATE_H
#include <qobject.h>

#ifdef BUILD_X86_WINDOWS
#include "../CommunicateDelegate/gSoapFoundation_windows/soapStub.h"
#else
#include "../CommunicateDelegate/gSoapFoundation/soapStub.h"
#endif
#include "communicatedelegate_global.h"
#include <qvector.h>
#include <qstring.h>
#include <QMutex>

class HmiCommunicate;

class   CommunicateNormalDelegate : public QObject
{
    Q_OBJECT
public:
    CommunicateNormalDelegate();
    ~CommunicateNormalDelegate();

public:
    int changeCurrentRobotId( int robotIdIn, int &returnFlag);
    int getLaserCameraBufferMoveConfigParameter(struct BufferMoveConfig &paraOut);
    int setLaserCameraBufferMoveConfigParameter(struct BufferMoveConfig paraIn,int &returnFlag);
    int getLaserTrackConfigParameter(struct LaserTrackConfig &paraOut);
    int setLaserTrackConfigParameter(struct LaserTrackConfig paraIn,int &returnFlag);
    int getControllerAllInformation( bool isContainIoData,bool isContainAgvData, bool isContainPointCloud,
                                                               ControllerInformationAll &infoOut);
    int addCircle(int idIn, std::vector<double> posIn, std::vector<double> centerIn,
                  std::vector<double> normalIn, double vel, int turnsIn, int velTypeIn,int &returnFlag);
    int addProgramMoveCommand_hmi(std::vector<struct MoveParameter> tmpCommandVectorIn, int &returnFlag);
    int getWeldDebugStatusInfo(struct WeldCraftStatusInfo& infoOut);
    int weldDebugOperation(enum E_WELD_TEST typeIn,bool control,int &returnFlag);
    int setWeldCollisionCheck(bool isCheck,int &returnFlag);

    int setToolMass(int toolIndex, double mass,std::vector<double> center,int &returnFlag);
    int getRobotCoordinateConfig(struct RobotCoordinateAxisConfig &configOut);
    int setRobotCoordinateConfig(struct RobotCoordinateAxisConfig configIn,int &returnFlag);

    int getBatteryPeakConfig(struct BatteryPeakConfig &configOut);
    int setBatteryPeakConfig(struct BatteryPeakConfig configIn,int &returnFlag);
    int getReflectLaserFilterParameter(int index,struct LaserFilterParameter &paraOut);
    int setReflectLaserFilterParameter(int index,struct LaserFilterParameter  paraIn,int &returnFlag);
    int getReflectCalculateCommonParameter(struct ReflectCommonDetectPara &paraOut);
    int setReflectCalculateCommonParameter(struct ReflectCommonDetectPara paraIn,int &returnFlag);
    int getAmclDebugInfo(struct AmclDebugInfo &debugInfoOut);


    int getOdometer(int robotIdIn,struct OdemeterData& odemeterDataReturn);
    int setEthernetIpAddress(std::string netNameIn,std::string ipIn,int &returnFlag);
    int getVehicleMovingCaligrateInfo(struct VehicleMovingCaligrateInfo &infoOut);
    int setCalibrateWheelDiameter(double idealMovedLength,double actualMovedLength,int &returnFlag);
    int setCalibrateWheelDistance(double idealMovedAngle,double actualMovedAngle,int &returnFlag);

    int setAmclPara(struct AmclDebugPara paraIn,int &returnFlag);
    int getAmclPara(struct AmclDebugPara &paraOut);
    int setSefetyCheck(enum E_SAFETY_CHECK typeIn,int isEnable,int &returnFlag);
    int getSefetyCheck(enum E_SAFETY_CHECK typeIn,int &checkStatusReturn);
    int setRollerMechanismConfig(struct RollerMechanismConfig configIn,int &returnFlag);
    int getRollerMechanismConfig(struct RollerMechanismConfig &configOut);
    int setLiftMechanismConfig(struct LiftMechanismConfig configIn,int &returnFlag);
    int getLiftMechanismConfig(struct LiftMechanismConfig &configOut);

    int getEncoderValue_belt(int beltIndexIn,int &encoderValueOut);
    int getEncoderValue_vision(int visionIndexIn, int &encoderValueOut);
    int forceConnectCamera(int visionIndex,int &returnFlag);
    int forceTrigCamera(int visionIndexIn, int isHighIn, int &returnFlag);
    int clearMotorBatteryError(int &returnFlag);
    int clearMotorBatteryErrorByAxis(int asixId,int &returnFlag);
    int setRobotSingleAxisCaliberate(int asixId,int &returnFlag);//会超时错误
    int setRobotAllAxisCaliberate(int &returnFlag);//会超时错误
    int getCoupleControlInfo(std::vector<struct CoupleConfigParameter> &infoOut);
    int setAxisProperty(int axisId, struct AxisProperty_hmi axisPropertyIn,int &returnFlag);
    int getAxisProperty(int axisId, struct AxisProperty_hmi &axisPropertyOut);
    int setCoupleRelativeDistanceMonitorEnable(int followAxisId,bool isEnableIn,int &returnFlag);
    int setCoupleControlEnable(int followAxisId,bool isEnableIn,int &returnFlag);
    int getImageStringFormImagePath(std::string imagePathIn,std::string &imageStrOut);
    int setWeldVirtualMode(bool isVirtualControlIn,int &returnFlag);
    int getWeldIsVirtualStatus(int &returnFlag);

    int getAgvBorderInfo(struct VehicleBorderInfo &infoOut);
    int setAgvBorderRectInfo(struct BorderRectInfo rectInfoIn,int &returnFlag);
    int getVehicleKinematicDimension(struct VehicleKinematicDimension &infoOut);
    int setVehicleKinematicDimension(struct VehicleKinematicDimension infoIn,int &returnFlag);
    int getLaserScanParameter(int laserId,struct LaserScanParameterHmi &infoOut);
    int setLaserScanParameter(int laserId,struct LaserScanParameterHmi infoIn,int &returnFlag);
    int getVehicleJogControlParameter(struct VehicleJogControlParameter &infoOut);
    int setVehicleJogControlParameter(struct VehicleJogControlParameter infoIn,int &returnFlag);
    int getVehicleTrajectoryControlParameter(struct VehicleTrajectoryControlParameter &infoOut);
    int setVehicleTrajectoryControlParameter(struct VehicleTrajectoryControlParameter infoIn,int &returnFlag);
    int getAgvSheftInfo(int id, struct BorderRectInfo &infoOut);
    int setAgvSheftRectInfo(int id,struct BorderRectInfo rectInfoIn,int &returnFlag);
    int getVehiclePositionCalibrateInfo(struct VehiclePosition &infoOut);

    int getLaserCameraConfigParameter( struct LaserCameraConfigParameter &infoOut);
    int getLaserCameraStatus( struct LaserCameraStatusInfo &infoOut);
    int setLaserCameraConfigParameter(struct LaserCameraConfigParameter parameter,int &returnFlag);
    int reconnectLaserCamera(int &returnFlag);
    int setLaserCameraWork(bool isWork, int &returnFlag);
    int setLaserCameraJobId(int jobIdIn, int &returnFlag);

    int calculateLaserCameraFrame(std::vector<struct PointPro> tcpPointList,
                                  std::vector<struct PointPro> cameraPointList,
                                  struct LaserCameraCalibrateResult &resultOut);
    int getLaserCameraFrameInfo(struct LaserCameraFrameInfo &infoOut);


    int getWeldSystemInfo(struct WeldSystemInfo &weldSystemInfo);
    int changeWeldSystemInfo(struct WeldSystemInfo configIn);
    int getPalletConditionInfo(std::vector<struct PalletMiddleInfo> &infoOut);
    int setPalletConditionInfo(struct StackInfo infoIn,int &returnFlag);
    int getWeaveMotionConditionInfo(std::vector<struct WeaveMotionCondition> &infoOut);
    int setWeaveMotionConditionInfo(struct WeaveMotionCondition infoIn,int &returnFlag);
    int getWeldConditionConfigList(std::vector<struct WeldCondition> &configListOut);
    int changeWeldConditionConfigList(struct WeldCondition configIn,int &returnFlag);
    int getWeldPropertConfigList(std::vector<struct WeldProperty> &configListOut);
    int changeWeldPropertConfigList(struct WeldProperty configIn,int &returnFlag);
    int getSocketFleetCommandLog(struct FleetCommandDebugInfo &fleetCommandLogOut);
    int getModbusFleetCommandLog(struct FleetCommandDebugInfo &fleetCommandLogOut);
    int getEncoderReciverDataList(std::vector<struct EncoderReceiverData> &dataListReturn);
    int getBeltTrackDebugInfo(int index,struct BeltTrackDebugInfo &infoOut);
    int getVisionTrackDebugInfo(int index,struct VisionTrackDebugInfo &infoOut);

    int getVisionTrackConfigList(std::vector<struct VisionTrackConfig> &configListOut);
    int getBeltTrackConfigList(std::vector<struct BeltTrackConfig> &configListOut);
    int changeVisionTrackConfig(int id,struct VisionTrackConfig configIn,int &returnFlag);
    int changeBeltTrackConfig(int id,struct BeltTrackConfig configIn,int &returnFlag);
    int getMapPropertyInfo(std::string mapName, MapPropertyInfo &infoOut);
    int getFleetMap(std::string mapName,std::string &mapInfoReturn);
    int writeFleetMap( std::string mapName, std::string &mapInfoIn);
    int calculateZeroOffset(std::vector<PointPro> pointList, AxisZeroOffsetInfo &returnInfo);
    int calibrateRobotByOffset(std::vector<double> offsetIn,int &returnFlag);

    bool isLogInStatus();
    int getAllReferenceMarks(std::vector<struct ReflectMarkInfo> &reflectMarksOut);
    int addReferenceMarkToMap(struct ReflectMarkInfo markIn,int &returnFlag);
    int saveReferenceMarkToFile(std::string fileNameIn,int &returnFlag);
    int deleteReferenceMarkInMap(int uniqId,int &returnFlag);
    int getReflectDebugInfo(struct ReflectDebugInfo &matchDebugInfoOut);
    int setOriginalLaserFilterType(int typeIn,int &returnFlag);

    int getSafeCollisionInfo(int sensorType, CollisionPara &infoOut);

    int setSafeCollisionInfo(int sensorType, struct CollisionPara infoIn,
                             int &returnFlag);
    int getRobotLogFileInfo(const int &robotIdIn, std::vector<struct Message> &messagesLogOut, int &returnFlag);

    /****************** Get Control IO ************************/
    /**
     * @brief get__Control_DO_NameInfo         获取控制器DO注释名
     * @param robotIdIn                        机器人编号
     * @param namesOut                         DO注释名列表
     * @param returnFlag                       执行状态返回  0:success -1:failed
     * @return                                 0:success -1:failed
     */
    int get__Control_DO_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);
    int get__Control_DI_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);
    int get__Control_AO_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);
    int get__Control_AI_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);
    int get__Control_SO_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);
    int get__Control_SI_NameInfo(const int &robotIdIn, std::vector<std::string> &namesOut, int &returnFlag);

    /****************** Set Control IO ************************/
    /**
     * @brief set_Control_DO_NameInfo       设置控制器DO注释名
     * @param robotIdIn                     机器人编号
     * @param logicValueIndexIn             逻辑值索引
     * @param nameIn                        目标注释名
     * @param returnFlag                    执行返回状态 0:success -1:failed
     * @return                              0:success -1:failed
     */
    int set_Control_DO_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);
    int set_Control_DI_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);
    int set_Control_AI_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);
    int set_Control_SI_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);
    int set_Control_SO_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);
    int set_Control_AO_NameInfo(const int &robotIdIn, const int &logicValueIndexIn, std::string nameIn, int &returnFlag);

    int getAllIoNamesinfo(const int &robotIdIn, IOMapNamesInfo &namesInfo, int &returnFlag);

    /**
     * @brief get_robot_program_files_strings           获取控制器执行文件信息
     * @param robotIdin                                 机器人编号
     * @param languageId                                语言编号
     * @param infoOut                                   执行程序信息
     * @return
     */
    int get_robot_program_files_strings(int robotIdin, int languageId, struct RunningProgramInfo &infoOut, int &returnFlag);
    int get_running_program_file_strings( int languageId, std::string fileName,std::vector<std::string> &infoOut);
    /**
     * @brief getRobotProgramFileList           获取程序文件列表
     * @param robotIdIn                         机器号
     * @param fileListOut                       程序文件列表
     * @param returnFlag                        返回标识 0:success -1:failed
     * @return                                  0:success -1:failed
     */
    int getRobotProgramFileList(int robotIdIn, std::vector <std::string> &fileListOut, int &returnFlag);

    /**
     * @brief removeRobotProgramFile            删除程序文件
     * @param robotIdIn                         机器号
     * @param fileName                          要删除的程序文件名
     * @param returnFlag                        返回标识 0:success -1:failed
     * @return                                  0:success -1:failed
     */
    int removeRobotProgramFile(int robotIdIn, std::string fileName, int &returnFlag);

    // gsoap读取写入程序文件
    /**
     * @brief readRobotProgramFile          gsoap读取程序文件
     * @param robotIdIn                     机器号
     * @param fileName                      文件名
     * @param fileStringOut                 文件字符输出
     * @return                              success:0   failed:-1
     */
    int readRobotProgramFile(int robotIdIn,std::string fileName, std::vector <std::string> &fileStringListOut, int &returnFlag);

    /**
     * @brief writeRobotProgramFile         gsoap写入程序文件
     * @param robotIdIn                     机器号
     * @param fileName                      文件名
     * @param fileStringIn                  写入文件的字符串
     * @param returnFlag                    返回标识    success:0   failed:-1
     * @return                              success:0   failed:-1
     */
    int writeRobotProgramFile(int robotIdIn,std::string fileName, std::vector <std::string> fileStringIn,int &returnFlag);

        //多线程同时调用可能会ｃｏｒｅdump
    int setDefaultProgramFile(std::string inProgramName,int &returnFlag);
    int setDefaultMapName(std::string fileNameIn, int &returnFlag);
    int setCheckVehiclePosition_amcl(bool isCheck,int &returnFlag);
    int setLaserIntensityFilterByType_visionMatch(int typeIn,int &returnFlag);
    int setUltrasonicSensorCheckEnable(bool isOn,int &returnFlag);
    int setPointCloudCheckEnable(bool isOn,int &returnFlag);
    int moveToNavgationPoint(struct MovingToNavagationParameter parameterIn,int &returnFlag);
//    int getVehiclePosition_specified(int typeIn,struct PositionInfo_hmi &positionReturn);
//    int getVMarkPositionInWorld( struct PositionInfo_hmi &positionReturn);
    int setCurrentVMarkIndex(int indexIn, int &returnFlag);
    int setCurrentVMarkType(int currentVmarkTypeIn,int &returnFlag);
    int getVmarkInfoList(std::vector<struct VMarkInfo> &vmarkInfoOut);
    int updateVMarkFile(std::string vmarkFileIn,int &returnFlag);
    int createVMark(struct VMarkInfo infoIn, std::string vmarkFileIn, int &returnFlag);
    int getMatchDebugInfo_vmark(struct VisionMatchDebugInfo &infoOut);
    int getQrcodeDebugInfo(QrcodeDebugInfo &infoOut);
    int setLaserFilterByType_vmark(int typeIn,int &returnFlag);

    bool isConnectedStatus();

    int manual_stop(int &returnFlag);
    int clear_odomter(int &returnFlag);
    int calibrateVehicle(double xOffset, double yOffset, double rOffset, int &returnFlag);
    int setVehicleBorderOffset_rect(double front_offsetIn,double back_offsetIn,
                               double left_offsetIn,double right_offsetIn,int &returnFlag);

    //获取类命令
//    int get_vehicle_basic_info(struct VehicleBasicInfo &basicInfoReturn);
    int get_map_list(std::vector<std::string> &mapNameListReturn);
    int getAllPointCloud_translated(std::vector<struct PointCloudData_3D> &pointCloudOut);
    int getCarBorder(std::vector<struct VehiclePosition> &carBorderOut);
    int getCarBorderOffset(std::vector<struct VehiclePosition> &carBorderOffsetOut);


    /*------------for agv----------------------*/
    int getCarSpeed(double& speed);
    int getBatteryLeft(double& batteryData);
    int getCarTask(QString& taskIn);
    int getCarStatus(int& statusIn);
    int getCarMode(int& carModeIn);

    int vehicleJog(double xMove, double yMove, double rotate, int &returnFlag);

    //地图
    int setMapSolver(enum E_MAP_SOLVER solverIn,
                     int laserCount,int &returnFlag);
    int createMapStart(int &returnFlag);
    int createMapEnd(std::string mapName,int &returnFlag);
    int loadMap(std::string mapName,int &returnFlag);
    int deleteMap(std::string mapName,int &returnFlag);
    int getCurrentMapName(std::string &mapNameOut);

    //添加虚拟墙
    int addVitrualBlock(std::string configFilePath,int &returnFlag);
    int deleteVitrualBlock(int &returnFlag);
    int addForbidenZone(double x_start,double y_start
                        ,double x_end,double y_end,int &returnFlag);

    //定位
    int setOdomSolver(enum E_ODOM_SOLVER solverIn,int &returnFlag);
    int setLocationSolver(E_LOCATION_SOLVER solverIn, int &returnFlag);
//    int getVehiclePosition(struct VehiclePosition& positionReturn);//以后不用，其它函数替代
    int setVehiclePosition(struct VehiclePosition positionIn,int &returnFlag);

    //轨迹规划和行驶
    int setReplanCoutLimitWhenFailure(int countLimit,int &returnFlag);
    int setTrajectoryGlobalPlanSolver(enum E_TRAJECTORY_GLOBAL_SOLVER solverIn,int &returnFlag);
    int setTrajectoryLocalPlanSolver(enum E_TRAJECTORY_LOCAL_SOLVER solverIn,int &returnFlag);
    int moveToPosition(struct VehiclePosition positionIn,
                       double velocity,int &returnFlag);
    int moveFollowPath(std::vector<struct VehiclePosition> pathIn,
                       double velocity,int &returnFlag);
    int changeVelocity(double velocity,int &returnFlag);
    int getMovingStatus(enum E_GOAL_STATUS& status);
    int getRemainningTime(double &timeOut);
    int getRemainningDistance(double &distanceOut);
    int ceaseMotion(int &returnFlag);
    int startMotion(int &returnFlag);
    int cancelMotion(int &returnFlag);

    //设置
    int setPositionArrivedAccuracy(double accuracyIn,int &returnFlag);
    int setLocalPlanRange(double rangeIn,int &returnFlag);
    int setVehicleBorderOffset(std::vector<double> point_x, std::vector<double> point_y,int &returnFlag);
    int setGlobalBarrierOffset(double offsetIn,int &returnFlag);
    int setLocalBarrierOffset(double offsetIn,int &returnFlag);
    int resetRosAll(int &returnFlag);

    //状态
    int getRosPackageStatus(enum E_ROS_PACKAGE package,enum E_ROS_PACKAGE_STATUS &status);

    //IMU校准
    int startImuCalibrate(int &returnFlag);
    int stopImuCalibrate(int &returnFlag);
    //-----------------------

    int restartNfsService(int &returnFlag);

    int getSdo(int robID,
                  int axis
                  , int rObIndex
                  , int rObSubIndex
                  , LONG64 &rData );

    int  setSdo(int robID, int axis
                 ,int wObIndex
                 ,int wObSubIndex
                 ,LONG64 wData
                 ,int wDataLen,int &returnFlag  );

    int setAllManualServon(int nServOffOn,int &returnFlag);

    int setAllRunModel(int runModel,int &returnFlag);

    int programAllRun(int &returnFlag);

    int programAllCease(int &returnFlag);

    int programAllReset(int &returnFlag);


    int getAllTaskInfo(std::vector<struct TaskManagerInfo> &taskManagerInfo);

    int getDebugInfo_motionServer(MotionDebugInfo &infoOut);

signals:

    int showEthercatSlavesInformationSignal(std::vector<EcatBusDevInfo_gsoap> slavesInfo );
    int showDebugInfo_motionServerSignal(MotionDebugInfo info);
    int showDebugInfo_programEngineSignal(std::vector<ProgramEngineDebugInfo> info);
    int showTaskInfoSignal(TaskManagerInfo taskInfo);

    int showCalibrateInfoSignal(S_AXISGROUP_ZERO_INFORMATION zeroInformationOut);

    /**
     * @brief sendConnectResult     发送 连接请求 结果
     * @param result
     */
    int sendConnectResult_signal(int result,QString note);

    /**
     * @brief sendFindConnectResult 发送 找到的可用ip
     * @param findIP
     */
    int sendFindConnectResult(QVector<QString> findIP);

    /**
     * @brief sendRegisterResult    发送 注册结果
     * @param findIP
     */
    int sendRegisterResult(ReturnRegisterStatus returnStatus);
    /**
     * @brief changePasswdResult    发送 密码修改结果
     * @param result
     */
    int changePasswdResult(int result);

    /**
     * @brief sendProPointChangeResult  发送 程序指令 点转换结果
     * @param sendPoint
     */
    int sendProPointChangeResult(PointPro sendPoint);
    /**
     * @brief sendPrPointChangeResult   发送 PR 点转换结果
     * @param sendPoint
     */
    int sendPrPointChangeResult(int index,PointPro sendPoint);

    /**
     * @brief sendToolCoordinateData    发送返回的坐标系数据
     * @param sendTool
     */
    int sendToolCoordinateData(QVector<HmiToolCoordinateInformation> sendTool);

    int sendUserCoordinateData(QVector<HmiUserCoordinateInformation> sendUser);
    /**
     * @brief sendToolCoordinateData    发送返回的计算的坐标系数据结果
     * @param sendTool
     */
    int sendToolCalculateData(HmiToolCoordinateInformation sendTool);

    int sendUserCalculateData(HmiUserCoordinateInformation sendUser);

    /**
     * @brief shutDownStart             启动关机提示
     */
    int shutDownStart(int shutDownS);

    /**
     * @brief showFileOperatDialog_signal       读写远程文件时显示临时窗口
     */
    int showFileOperatDialog_signal(int msgBoxType,QString title,QString text);

    /**
     * @brief sendLogFileInfo_Signal            发送日志
     * @param logInfo                           日志内容
     */
    int sendLogFileInfo_Signal(QVector <struct Message> logInfo);

public slots:


    int stopRun();//停止运动槽
    int stopWatchDog();
    int pauseRunSlot();//暂停运动槽

    int runSlot();//运行按钮触发槽
    int setManualServonSlot(int onOff);//使能电机

    /**
     * @brief returnZeroSlot        回零
     * @param axisNum               回零的轴
     */
    int returnZeroSlot(int axisNum);

    /**
     * @brief returnZeroSlot        回零
     * @param axisNum               回零的轴
     */
    int returnZeroSlot();
    int jogRunDogSlot();

    /**
     * @brief getLogFileInfo_Slot       开始获取日志文件信息
     */
    int getLogFileInfo_Slot();

    int setMotorDcModeSlot(int value);
    int clearMotorBatteryErrorSlot();
    int getEthercatSlavesInformationSlot();
    int writeEthercatDeviceAliasSlot(int nodeId,int alias);
    int getDebugInfo_motionServerSlot();
    int getDebugInfo_programEngineSlot();
    int getTaskInfoSlot();

    int getCalibrateInformation(S_AXISGROUP_ZERO_INFORMATION &zeroInformationOut);
    int getCalibrateInformationSlot();

    int allowCalibrateJogSlot(bool enable);

//    int calibrateOneAxisSlot(int axisId);


    //登录与初始化*********
    /**
     * @brief updateTmpInfo         登陆时 跟新用户数据
     */
    int updateTmpInfo(QString serverIP);
    int setUserInfo(UserInfo userInfoIn);

    /**
     * @brief tryToConnect          连接尝试
     */
    int tryToConnect(QString hmiVersionInfo);
    /**
     * @brief tryToConnect          连接 寻找可用连接
     */
    int findConnect();
    /**
     * @brief stopFindConnect       停止寻找
     */
    int stopFindConnect();
    /**
     * @brief findConnectTimeWork   每100ms查询一个
     */
//    int findConnectTimeWork();

    /**
     * @brief readDefaultFileNameSlot 返回缺省文件名字,并且打开文件
     */
    int readDefaultFileNameSlot();

    /**
     * @brief setLanguageSlot           设置语言
     */
    int setLanguageSlot(int languageID);







    /**
     * @brief runSlot               设置运行的行号触发槽
     */
    int setRunLineSlot(int number);


    /**
     * @brief setHandWheelSlot      滚轮
     */
    int setHandWheelSlot(int axisNumber, int direction, int velocity);

    //顶部栏 设置********
    /**
     * @brief setManualSpeedSlot    设自动速度
     * @param setSpeed
     */
    int setManualSpeedSlot(float setSpeed);
    /**
     * @brief setAutoSpeedSlot      设手动速度
     * @param setSpeed
     */
    int setAutoSpeedSlot(float setSpeed);

    /**
     * @brief setDebugMode          设置 手动 单步/连续
     * @param debugMode
     */
    int setDebugModeSlot(int debugMode);

    /**
     * @brief setJointCoordinateSlot    设置手动坐标系
     * @param jointCoordinate
     */
    int setJointCoordinateSlot(int jointCoordinate);

    /**
     * @brief setControlMaunalModeSlot  设置运行模式(手动T12,自动,EX,FLEET)
     * @param runModel
     */
    int setControlMaunalModeSlot(int runModel);

    //设置 激活坐标系ID
    int setCurrentToolCoordSlot(int toolID);
    int setCurrentUserCoordSlot(int userID);

    //运程界面
    /**
     * @brief cleanCurrentCounter                   清空当前
     */
    int cleanCurrentCounter();
    /**
     * @brief cleanAllCounter                       清空所有
     */
    int cleanAllCounter();
    /**
     * @brief setProgramRunLine                     设置运行行号
     */
    int setProgramRunLineSlot(int line);

    int clearCurrentProductionSlot();

    int clearAccumulatedProductionSlot();

    //程序界面
    /**
     * @brief openFileCommSlot                      打开文件
     * @param fileName
     */
    int openFileCommSlot(QString fileName);//soap_call_setProgramFileName
    /**
     * @brief saveFileAndUpdateCtrlSlot             编辑后保存,通知更新控制器的文件
     * @param fileName
     * @param md5
     */
    int saveFileAndUpdateCtrlSlot(QString fileName,QString md5);//updateUserProgramFile



    /**
     * @brief changePointTypeSlot                   程序内(指令编辑 点查看) 转换点(根据页面存在与否显示)
     * @param inputPointPro
     */
    int changePointTypeSlot(PointPro inputPointPro);

    //IO界面
    int setDoSlot(int number,bool value);

    int setSoSlot(int number,bool value);          //2017.02.13补充 soap 接口

    int setAoSlot(int number,float value);         //2017.02.13补充 soap 接口

    int setGrSlot(int number,float value);
    int cleanAllGrSLot();

    int setRSlot(int number,float value);
    int cleanAllRSLot();

    int recordPrSlot(int number,PointPro tmpPoint);
    //int prMoveToPointSlot(MoveParameter movePoint);
    int changePrTypeSlot(int index,PointPro inputPointPro);  //界面 尚无对应按钮

    int setPlSlot(int number,float row,float col,float layer);
    int cleanAllPlSlot();

    int setTimeSlot(int number,int changeStatus);  //尚无接口

    //消息界面
    /**
     * @brief cleanMsgSLot              清除一条信息
     * @param msgID
     */
    int cleanMsgSLot(int msgID);
    /**
     * @brief cleanAllMsgSlot           清除全部信息
     */
    int cleanAllMsgSlot();
    int clearMsgAndServoOn();

    //菜单界面
    /**
     * @brief setSingleCaliberSlot      单轴标定
     * @param asixId
     */
//    int setSingleCaliberSlot(int asixId);
    /**
     * @brief setAllCaliberSlot         全轴标定
     */
//    int setAllCaliberSlot();
    /**
     * @brief changePasswordSlot        修改密码
     */
    int changePasswordSlot(int acc, QString oldPass, QString newPass);
    /**
     * @brief changeCtrlIPSlot          修改控制器IP
     * @param IP
     */
    int changeCtrlIPSlot(ControllerIpGroupInfo tmpInfo);
    /**
     * @brief setRegisterNumberSlot     输入注册码 注册
     */
    int setRegisterNumberSlot(QString registerNumber);

    /**
     * @brief getToolCoordinate         获取工具坐标系数据
     */
    int getToolCoordinateSlot(int robotID);
    /**
     * @brief getUserCoordinate         获取用户坐标系数据
     */
    int getUserCoordinateSlot(int robotID);

    /**
     * @brief calculateToolCoordinate   计算工具坐标系
     * @param resultToolCoordinate
     */
    int calculateToolCoordinate(int robotID,HmiToolCoordinateInformation sendToolCoordinate);

    /**
     * @brief calculateUserCoordinate   计算用户坐标系
     * @return resultUserCoordinate
     */
    int calculateUserCoordinate(int robotID,HmiUserCoordinateInformation sendUserCoordinate);

    /**
     * @brief changeAxisLimit			设置 软限位
     */
    int changeAxisLimitSlot(QVector<AxisLimit> changeLimit);

    /**
     * @brief getStoreStatus			hmi获取 存储状态
     */
    int getStoreStatusSlot();//获取 存储状态

    int controllerShutDownEnableSlot(bool enable);

    /**
     * @brief setStartTypeSlot          设置 启动模式
     */
    int setStartTypeSlot(int type);
    /**
     * @brief shutDownSlot              设置 关机
     */
    int shutDownSlot();


    /**
     * @brief connectVrep				连接vrep
     * @return
     */
    int connectVrep(QString ip,int port);

    /**
     * @brief disconnectVrep			断开连接vrep
     * @return
     */
    int disconnectVrep();

    /**
     * @brief setVrepServoType			设置vrep伺服模式
     * @return
     */
    int setVrepServoType(int type);

    /**
     * @brief setVrepIoType				设置vrep IO模式
     * @return
     */
    int setVrepIoType(int type);
    
    int backupFile(int backUpType,int diskType,
                   std::string fileName,int robotId,int &returnFlag);
    
    int restoreFile(int backUpType,int diskType,
                    std::string fileName, int robotId,int &returnFlag);

    int getFileList(int pathType, std::vector<std::string> &fileList);





public:


    HmiCommunicate *hmiCommunicate;
    //用于临时缓存
    struct UserInfo tmpUserInfo;
    QString tmpServerIp;
    QByteArray tmpServerIpArray;//gsoap直接用包含port

    /**
     * @brief findConnectTimer      查询IP定时器
     */
//    QTimer *findConnectTimer;
    /**
     * @brief findCount             已查询可用IP个数累计
     */
//    int findCount;
    /**
     * @brief ipNumber              IP最后一位数值
     */
    int ipNumber;
    /**
     * @brief findIP                可用IP容器
     */
    QVector<QString> findIP;

    bool isConnected;

    bool isLogIn;//是否已经登录

    QMutex usingMutex;//避免多线程同时调用

};

#endif // COMMUNICATENORMALDELEGATE_H
